let app=getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        size:8
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let that=this;
        this.getNotice();
        that.setData({
            width:app.globalData.windowWidth,
            height:app.globalData.windowHeight,
            statusBarHeight:app.globalData.statusBarHeight,
            navHeight:app.globalData.navHeight,
            marginTop:app.globalData.navTitleTop
          })
    },
    goBack(){
     wx.navigateBack();
    },
    getNotice:function(){
        var open=wx.getStorageSync('open');
        var member_id=open.member_id;
        
        var size=this.data.size;
        let that=this;
        wx.request({
          url: app.globalData.domain+'member/notice/getNoticeList',
          data:{open_id:open.id,member_id:member_id,from:5,page:1,size:size},
          success:res=>{
              console.log(res);
              var more=0;
              var list=res.data.noticeList;
              var count=list.length;
              if(count==size){
                more=1;
              }
              that.setData({
                  list:list,
                  page:1,
                  more:more
              })
          }
        })
    },
    goto:function(e){
        var id=e.currentTarget.dataset.id;
        var notice_id=e.currentTarget.dataset.notice_id;
        wx.navigateTo({
          url: 'detail?id='+id+"&notice_id="+notice_id,
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
      var open=wx.getStorageSync('open');
      var member_id=open.member_id;
     
      var size=this.data.size;
      let that=this;
      var page=this.data.page;
      var nowpage=page+1; 
      var noticeList=this.data.list   
       wx.request({
        url: app.globalData.domain+'member/notice/getNoticeList',
        data:{open_id:open.id,member_id:member_id,from:5,page:nowpage,size:size},
        success:res=>{
            console.log(res);
            var more;
            var list=res.data.noticeList;
            var nowList;
            var count=list.length;
            if(count<size){
              more=0;
            }else{
              more=1;
            }
            if(count>0){
              nowList=motoceList.concat(list);
            }else{
              nowpage=page;
              nowList=list;
            }
            that.setData({
                list:list,
                page:nowpage,
                more:more
            })
        }
      })

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    onRefresh: function() {
        this.onLoad()
        //this.onReady()
      }

})